import axios from "axios";

// axios.defaults.baseURL = 'http://10.161.35.224'

// axios.defaults.headers = {
//
// }

/* api here */
const test = () => {
  return axios.get('/flask/api')
}

const realTimePower = () => {
  return axios.get('/flask/api/realTimePower')
}

const abnormalList = () => {
  return axios.get('/flask/api/abnormalList')
}

const abnormalCount = () => {
  return axios.get('/flask/api/abnormalCount')
}

const dataByBuildingTypeNTimeType = (buildingType, timeType) => {
  return axios.post('/spring/api/hive/getData',{
    buildingType:buildingType,
    timeType: timeType
  })
}

const dataByBuildingIdNTimeType = (buildingId, timeType) => {
  return axios.post('/spring/api/hive/getData',{
    buildingId:buildingId,
    timeType: timeType,
    buildingType: 'building'
  })
}

const dormDataByDay = (buildingId, roomId) => {
  return axios.post('/spring/api/hive/getData',{
    buildingId:buildingId,
    roomId: roomId,
    timeType: 'week',
    buildingType: 'dorm'
  })
}

const topN = () => {
  return axios.get('/spring/api/hive/getTopDorm')
}

const updateTime = () => {
  return axios.get('/spring/api/hive/getUpdateTime')
}


const api = {
  test,
  realTimePower,
  abnormalList,
  abnormalCount,

  dormDataByDay,
  dataByBuildingTypeNTimeType,
  dataByBuildingIdNTimeType,

  topN,
  updateTime
}

export default api
